<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<!--<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">-->
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="css/index.css">
    <script language="JavaScript" src="js/index.js"></script>
</head>
<body>
<div id="div_container">
    <div id="div_fruit_list">
        <div style="border: 1px solid red; width: 60%; margin-left: 20%; text-align: right;">
<!--            <form th:action="@{/index}" method="post">-->
            <form th:action="@{/fruit.do}" method="post">
                <input type="hidden" name="oper" value="search">
                请输入查询关键字: <input type="text" name="keyword" th:value="${session.keyword}">
                <input type="submit" value="查询" class="btn">
            </form>
            <!-- 此次页面跳转没有经过服务器渲染thymeleaf 导致后续添加一直不跳转 -->
            <a th:href="@{add.html}" style="border: 1px solid blue; margin-bottom: 4px;">添加</a>
        </div>
        <table id="tbl_fruit">
            <tr>
                <th class="w20">名称</th>
                <th class="w20">单价</th>
                <th class="w20">库存</th>
                <th>操作</th>
            </tr>
            <tr th:if="${#lists.isEmpty(session.fruitList)}">
                <td colspan="4">对不起, 库存为空</td>
            </tr>
            <tr th:unless="${#lists.isEmpty(session.fruitList)}"
                th:each="fruit : ${session.fruitList}">
                <!--                <td><a th:text="${fruit.fname}" th:href="@{'/edit.do?fid=' + ${fruit.fid}}"></a></td>-->
<!--                <td><a th:text="${fruit.fname}" th:href="@{/edit.do(fid=${fruit.fid})}"></a></td>-->
                <td><a th:text="${fruit.fname}" th:href="@{/fruit.do(fid=${fruit.fid},operate='edit')}"></a></td>
                <td th:text="${fruit.price}"></td>
                <td th:text="${fruit.fcount}"></td>
                <td><img src="imgs/del.jpg" class="delImg" th:onclick="|delFruit(${fruit.fid})|"/></td>
            </tr>
        </table>
        <div style="width: 60%; margin-left: 20%;">
            <input type="button" value="首  页" class="btn" th:onclick="|page(1)|" th:disabled="${session.pageNo == 1}">
            <input type="button" value="上一页" class="btn" th:onclick="|page(${session.pageNo - 1})|" th:disabled="${session.pageNo == 1}">
            <input type="button" value="下一页" class="btn" th:onclick="|page(${session.pageNo + 1})|" th:disabled="${session.pageNo == session.pageCount}">
            <input type="button" value="尾  页" class="btn" th:onclick="|page(${session.pageCount})|" th:disabled="${session.pageNo == session.pageCount}">
        </div>
    </div>
</div>
</body>
</html>